﻿using System;
using System.Data.SqlClient;
using System.Data;

namespace Eassets.Data.Asset
{
    public class TransactionSerialData
    {
        public long GetMaxTransactionSerialByWorkFlowDocumentCode(String documentCode)
        {
            long resultsList = 0;
            SqlCommand command = new SqlCommand("SP_GetLastTransactionSerial");
            command.Parameters.AddWithValue("@WorkFlowDocumentCode", documentCode);
            command.CommandType = CommandType.StoredProcedure;

            CommonData commonData = new CommonData();
            SqlDataReader dataReader = commonData.ExecuteReader(command);
            while (dataReader.Read())
            {
                resultsList = Convert.ToInt16(dataReader["SERIAL"]);
            }

            return resultsList;
        }

        public void UpdateTransactionSerial(string workFlowDocCode)
        {
            SqlCommand command = new SqlCommand("SP_UpdateTransactionSerial");
            command.Parameters.AddWithValue("@WorkFlowDocumentCode", workFlowDocCode);
            command.CommandType = CommandType.StoredProcedure;
            CommonData commonData = new CommonData();
            commonData.ExecuteNonQuery(command);
        }
    }
}
